package com.example.biye;

import androidx.appcompat.app.AppCompatActivity;

import android.Manifest;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;


import com.example.biye.permission.CustomPermissionUtil;
import com.example.biye.permission.PermissionCallback;
import com.example.biye.permission.RequestBean;


public class JinjiActivity extends AppCompatActivity {
    private SharedPreferences jinjiShared;
    private EditText test_jinjixingming;
    private EditText test_jinjidianhua;




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_jinji);
        getSupportActionBar().hide();
        jinjiShared = getSharedPreferences("share_jinji", MODE_PRIVATE);
        test_jinjixingming = (EditText) findViewById(R.id.test_jinjixingming);
        test_jinjidianhua = (EditText) findViewById(R.id.test_jinjidianhua);
        String jinjixingming = jinjiShared.getString("jinjixingming", "");
        String jinjidianhua = jinjiShared.getString("jinjidianhua", "");
        test_jinjixingming.setText(jinjixingming);
        test_jinjidianhua.setText(jinjidianhua);
        Button buttonjinjibaocun = (Button) findViewById(R.id.buttonjinjibaocun);
        buttonjinjibaocun.setOnClickListener(
                new View.OnClickListener() {
                    @Override
                    public void onClick(View v) {
                        String jinjixm = test_jinjixingming.getText().toString();
                        String jinjidh = test_jinjidianhua.getText().toString();
                        if(jinjidh.length() != 0&& jinjixm.length() != 0) {
                            SharedPreferences.Editor editor = jinjiShared.edit();
                            editor.putString("jinjixingming", test_jinjixingming.getText().toString());
                            editor.putString("jinjidianhua", test_jinjidianhua.getText().toString());
                            editor.commit();
                            Toast.makeText(JinjiActivity.this, "保存成功", Toast.LENGTH_SHORT).show();
                        }
                        else {
                            Toast.makeText(JinjiActivity.this, "请完善信息", Toast.LENGTH_SHORT).show();
                        }
                    }
                }
        );
    }

}